<%@ page import="databeans.*"%>
<%
	Employee employee = (Employee)session.getAttribute("employee");
	String employeeUsername = employee.getUsername();
	String employeeFirstName = employee.getFirstName();
	String employeeLastName = employee.getLastName();
	String[] minD = (String[])request.getAttribute("minD");

%>
<jsp:include page="../common/header.jsp" />
<script type="text/javascript" src="view/js/ui/ui.datepicker.js"></script>

<script type="text/javascript">
	$(document).ready(function() {
		 
		$("#datepicker").datepicker({minDate:new Date(<%=minD[0]%>,<%=minD[1]%>,<%=minD[2]%>) ,showOn: 'button', buttonImage: 'view/img/icons/calendar.png', buttonImageOnly: true, dateFormat: 'yy-mm-dd', hideIfNoPrevNext: true});
		$(".ui-datepicker-trigger").attr('title','Choose a Date');
	});
</script>


<title>Carnegie Financial Services - Transition Day Manager</title>
</head>

<body>
	<div id="container">
    	<div id="header">
        	<h2>Carnegie Financial Services</h2>
    		<jsp:include page="../common/top-menu.jsp" />
      	</div>
        <div id="wrapper">
        	<div id="content">
              <div id="box">
	            	<h3>Transition Day</h3>
	            	<jsp:include page="../common/messages.jsp" />
	                <form id="form" action="employeeExecuteTransition.do" method="post">
	                    <label for="date">Date: </label> 
	                    <input name="transDate" id="datepicker" type="text" tabindex="1" value="${transDate}"/>
	                    <br />
	                    
	                    	<% if (request.getAttribute("fundsDateOfLastTransaction")!=null) { %>
	
	<p>Date of last transaction: <%= request.getAttribute("fundsDateOfLastTransaction") %></p>
	
	<% } %>
	                    
	                    <div>
	                    <% 
	                   		int i=0;
		                    Fund [] fundsList = (Fund[])request.getAttribute("fundsList");
		                    String [] errorPrices = (String[])request.getAttribute("fundsErrorPrices");
							double [] fundsPrices = new double[0];
							if (fundsList != null){ 
						%>
		                    <table>
								<thead>
									<tr>
										<th>ID</th>
		                            	<th>Fund</th>
		                            	<th>Symbol</th>
		                            	<th>Last Price</th>
		                                <th>New Price</th>
		                            </tr>
								</thead>
								<tbody>
									
									<%
									    //fundsList = (Fund[])request.getAttribute("fundsList");
									    fundsPrices = (double[])request.getAttribute("fundsPrices");
									    
										for (i = 0; i < fundsList.length; i++) {
											Fund tempFund = fundsList[i];
											//double tempPrice = fundsPrices[i];
											%>
									<tr>
										<td><%= i+1 %></td>
		                            	<td><%= tempFund.getName() %></td>
										<td><%= tempFund.getSymbol() %></td>
										<td>$<%=fundsPrices[i]%></td>
		                                <td><input type="text" name="txtNewFundPrice<%= tempFund.getFundID() %>" size="10" value="<% if (errorPrices!=null) { out.println(errorPrices[i]); } %>" tabindex="<%=i+1 %>"/></td>
		                            </tr>
		                            <%} %>
								</tbody>
							</table>
							<%}else
								out.println("No funds found in Database!");
								%>
		                  </div>
		                  <div class="padding"></div>
	                  <div align="center">
		                  <input name="Submit" id="button1" type="submit" value="Submit" tabindex="<%=2+i+1 %>" /> 
		                  <input id="button2" type="reset" tabindex="<%=2+i+2 %>" value="Cancel" />
	                  </div>
	                </form>
                </div>

            </div>

            <jsp:include page="../common/sidebar.jsp" />
      </div>
        <jsp:include page="../common/footer.jsp" />
</div>
<div id="popup" ></div>
</body>
</html>
